Advanced C++ and Software Engineering Interview Questions: Beyond The Invisible by Gleamixie

Advanced C++ and Software Engineering Interview Questions: Beyond The Invisible by Gleamixie

Author:Gleamixie
Language: eng
Format: epub
Published: 2025-02-16T00:00:00+00:00


In this example, the parent process creates a pipe and then forks a child process. The parent writes the string “Hello Child” to the pipe, and the child reads this string from the pipe and writes it to stdout. The pipe is unidirectional , so data written by the parent is read by the child.

​2. ​ Named Pipes (FIFOs)

Named pipes, also known as FIFOs, are similar to unnamed pipes but have a name in the file system. They allow bidirectional communication between processes and can be used for IPC between unrelated processes.

This example includes two programs, one that writes to the pipe first and then reads from it, and another that reads from the pipe first and then writes to it.

Program 1 | Writes First | program1.cpp

#include <fcntl.h>

#include <sys/stat.h>

#include <sys/types.h>

#include <unistd.h>

#include <string.h>

#include <stdio.h>

int main () {

int fd;

const char * m_fifo = "/tmp/myfifo" ;

mkfifo ( m_fifo , 0666 ) ;

char w_data [ 80 ] , r_data [ 80 ] ;

while ( 1 ) {

fd = open ( m_fifo , O_WRONLY ) ;

fgets ( w_data , 80 , stdin) ;

write ( fd, w_data, strlen ( w_data ) + 1 ) ;

close ( fd ) ;

fd = open ( m_fifo , O_RDONLY ) ;

read ( fd, r_data, sizeof ( r_data )) ;

printf ( "Process-2: %s
" , r_data ) ;

close ( fd ) ;

}

return 0 ;

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(56018)
What's Done in Darkness by Kayla Perrin(26591)
The Fifty Shades Trilogy & Grey by E L James(19078)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19057)
Shot Through the Heart by Mercy Celeste(18935)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17110)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16989)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16873)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16823)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16444)
The Subtle Art of Not Giving a F*ck by Mark Manson(14352)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14128)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13622)
Scorched Earth by Nick Kyme(12767)
Drei Generationen auf dem Jakobsweg by Stein Pia(10964)
Suna by Ziefle Pia(10888)
Scythe by Neal Shusterman(10334)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9520)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9366)
The Ultimate Python Exercise Book: 700 Practical Exercises for Beginners with Quiz Questions by Copy(9318)